export default{
    data(){
        return{
            list: [],
            modal1: false,
            ids:[],
            filter:{
                page:1,
                rows:2,
                total:0,
                name:'',
                title:'',
                cateId:'',
                userId:'',
                newsId:'',
                content:''
            }
          }
    },
    methods:{
    alldeletd(){
      //console.log('id:'+this.ids);
      this.$http({
          method:'post',
          url: `http://localhost:3000/${this.module}/removes/`+this.ids
        }).then(response=>{
          //console.log('remove:============>'+response.data);
          
        })
        parent.location.reload();
        /*for(var i=0;i<this.ids.length;i++){
            this.deleteData(this.ids[i]);
        }*/
      },
    allNode(event){
      console.log(event);
      this.id='';
      for(var i=0;i<event.length;i++){
          this.ids.push(event[i]._id);
      }
    },
        addData(){

            this.id='';
            this.modal1 = true;
          },
        editData(id){
             this.id=id;
             this.modal1 = true;
             this.$http({
              method:'get',
              url: `http://localhost:3000/${this.module}/data/`+id
            }).then(response=>{
              //console.log('get:============>'+response.data);
              this.formValidate=response.data;
            })
          },
        deleteData(id){
            this.$http({
              method:'delete',
              url: `http://localhost:3000/${this.module}/data/`+id
            }).then(response=>{
              console.log('delete:============>'+response.data);
              this.formValidate = response.data;
            })
            this.getData();
          },
        search(){
            this.getData();
        },
        changePageSize(pagesize){
            this.filter.rows=pagesize;
            this.getData();
            
        },
        changePage(page){
            this.filter.page=page;
            this.getData();
        },
        getData(){
      // if(getCookie('userId')){
      //   this.filter.userId=getCookie('userId');
      // }
      // if(getCookie('newsId')){
      //   this.filter.newsId=getCookie('newsId');
      // }
            this.$http({
              method:'post',
              url: `http://localhost:3000/${this.module}/list`,
              data:this.filter
            }).then(res=>{
              console.log(res.data);
              this.list=res.data.rows;
              this.filter.total=res.data.total;
              this.filter.newsId=this.$route.params.id;
              console.log(this.filter.newsId)
              // console.log(this.list)
              // console.log(this.filter.total)
              //console.log(res.data.rows[0].name);
            })
          
        }
    },
    created(){
        this.getData();
    }
}
